home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS03.ADF / Xref / type.c < prev    next >
Text File  |  1986-04-02  |  2KB  |  111 lines

  1. /**************************************************************************
  2.  
  3. NAME
  4.  
  5.    type -- return type of character: letter or digit
  6.  
  7. SYNOPSIS
  8.  
  9.    t = type(c);
  10.    int t;        returned as LETTER or DIGIT or character itself
  11.    int c;        input character
  12.  
  13. CAUTIONS
  14.  
  15.    'LETTER' and 'DIGIT' must be equally defined in calling routines.
  16.    The value of LETTER must be from a-z or A-Z and the value of DIGIT 0-9.
  17.  
  18. AUTHOR    Philip T. Ansteth
  19. DATE      Dec. 6, 1985
  20. CLIENT    ANSTETH RESEARCH
  21.  
  22. **************************************************************************/
  23.  
  24. #define LETTER 'a'
  25. #define DIGIT '0'
  26.  
  27. type(c)  /* return type of ASCII character */
  28. int c;
  29. {
  30.  
  31. /*   if(c >= 'a' && c <='z' || c >= 'A' && c <= 'Z')
  32.    if(isalpha(c))
  33.       return(LETTER);
  34.    else if (c >= '0' && c <= '9')
  35.    else if(isdigit(c))
  36.       return(DIGIT);
  37.    else
  38.       return(c);        */
  39.    switch(c) {
  40.       case 'a':
  41.       case 'b':
  42.       case 'c':
  43.       case 'd':
  44.       case 'e':
  45.       case 'f':
  46.       case 'g':
  47.       case 'h':
  48.       case 'i':
  49.       case 'j':
  50.       case 'k':
  51.       case 'l':
  52.       case 'm':
  53.       case 'n':
  54.       case 'o':
  55.       case 'p':
  56.       case 'q':
  57.       case 'r':
  58.       case 's':
  59.       case 't':
  60.       case 'u':
  61.       case 'v':
  62.       case 'w':
  63.       case 'x':
  64.       case 'y':
  65.       case 'z':
  66.       case 'A':
  67.       case 'B':
  68.       case 'C':
  69.       case 'D':
  70.       case 'E':
  71.       case 'F':
  72.       case 'G':
  73.       case 'H':
  74.       case 'I':
  75.       case 'J':
  76.       case 'K':
  77.       case 'L':
  78.       case 'M':
  79.       case 'N':
  80.       case 'O':
  81.       case 'P':
  82.       case 'Q':
  83.       case 'R':
  84.       case 'S':
  85.       case 'T':
  86.       case 'U':
  87.       case 'V':
  88.       case 'W':
  89.       case 'X':
  90.       case 'Y':
  91.       case 'Z':
  92.          return(LETTER);
  93.          break;
  94.       case '0':
  95.       case '1':
  96.       case '2':
  97.       case '3':
  98.       case '4':
  99.       case '5':
  100.       case '6':
  101.       case '7':
  102.       case '8':
  103.       case '9':
  104.           return(DIGIT);
  105.           break;
  106.       default:
  107.           return(c);
  108.    }
  109.  
  110. }
  111.